<% layout('/layouts/default.html', {title: '任务管理', libs: ['validate']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${task.id == 0 ? '新增作业调度' : '编辑作业调度'}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${task}" action="${ctx}/schedule/task/save" method="post" class="form-horizontal">
			<#form:hidden path="id"/>
			<div class="box-body">
				<div class="form-unit">基本信息</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> 任务名称：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="jobName" maxlength="32" readonly="${!(task.id == 0)}" class="form-control required "/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> 调用目标：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="jobClassName" maxlength="250" class="form-control required "/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> 任务描述：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:input path="jobDescription" maxlength="250" class="form-control required "/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> Cron执行表达式：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden path="cronExpression" maxlength="255" class="form-control required "/>
								<iframe id="cronFrame" src="${ctxStatic}/cron-quartz/index.html?ctx=${ctx}" style="width:660px;height:530px;border:0"></iframe>
								<script type="text/javascript">
									$('#cronFrame').load(function(){
										var win = $(this)[0].contentWindow;
										win.$('#cron').val($('#cronExpression').val());
										win.$("input[name^='v_'],#cron").change(function(){
											$('#cronExpression').val(win.$('#cron').val());
										});
										win.$('#btnFan').click();
									});
								</script>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('schedule:task:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> 关 闭</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		if ($('#cronExpression').val($('#cronFrame')[0].contentWindow.$('#cron').val()).val() == ''){
			js.showMessage('请填写Cron表达式！', '', 'warning');
			return false;
		}
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>
